<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>人员信息修改</title>
</head>
<body>
<h1>人员信息修改</h1>
<div>
    <label>
        <input type="text" v-model="user.id" placeholder="id" readonly>
    </label><br>
    <label>
        <input type="text" v-model="user.username" placeholder="username">
    </label><br>
    <label>
        <input type="password" v-model="user.password" placeholder="password">
    </label><br>
    <label>
        <input type="text" v-model="user.nick" placeholder="nick">
    </label><br>
    <input type="button" value="修改" @click="update()">
</div>
<script src="js/vue.js"></script>
<script src="js/axios.min.js"></script>
<script>
    let v = new Vue({
        el:"div",
        data:{
            user:{}
        },
        created:function (){
            let id = location.search.split("=")[1];
            axios.get("/selectUserById?id=" + id).then(function (response) {
                console.log(v.user);
                v.user = response.data;
            });
        },
        methods:{
            update() {
                axios.post("/updateUserById", v.user).then(function () {
                    alert("修改成功!")
                    location.href="listUser.html";
                });
            }
        }
    })
</script>
</body>
</html>